package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.WorkshopEntity;
import com.chenxin.wms.service.IWorkshopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 产线管理Controller
 *
 * @author loujf
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/wms/workshop")
public class WorkshopController extends BaseController {
    @Autowired
    private IWorkshopService workshopService;

    /**
     * 查询产线管理列表
     */
    @PreAuthorize("@ss.hasPermi('wms:workshop:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkshopEntity workshopEntity) {
        startPage();
        List<WorkshopEntity> list = workshopService.selectWorkshopList(workshopEntity);
        return getDataTable(list);
    }

    /**
     * 导出产线管理列表
     */
    @PreAuthorize("@ss.hasPermi('wms:workshop:export')")
    @Log(title = "产线管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkshopEntity workshopEntity) {
        List<WorkshopEntity> list = workshopService.selectWorkshopList(workshopEntity);
        ExcelUtil<WorkshopEntity> util = new ExcelUtil<WorkshopEntity>(WorkshopEntity.class);
        util.exportExcel(response, list, "产线管理数据");
    }

    /**
     * 获取产线管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:workshop:query')")
    @GetMapping(value = {"/", "/{lineId}"})
    public AjaxResult getInfo(@PathVariable(value = "lineId", required = false) Long lineId) {
        return success(workshopService.selectWorkshopByLineId(lineId));
    }
}
